﻿using System;
using System.Collections.ObjectModel;
using System.Windows.Input;
using Microsoft.Practices.Prism.Commands;
using Synology.AudioStationApi;

namespace PartTwo
{
    public class SearchResultViewModel : ISearchResultViewModel
    {
        private readonly IPlayerService _playerService;
        public SynoTrack TrackInfo { get; set; }

        public SearchResultViewModel(SynoTrack synoTrack, IPlayerService playerService)
        {
            _playerService = playerService;
            TrackInfo = synoTrack;
            PlayCommand = new DelegateCommand( OnPlayCommandExecuted,  () => true);
            AddToPlaylistCommand = new DelegateCommand(OnAddToPlaylistCommandExecuted, () => true);
        }

        private void OnAddToPlaylistCommandExecuted()
        {
            _playerService.AddTrackToPlaylist(TrackInfo);
        }

        private void OnPlayCommandExecuted()
        {
            _playerService.PlayTrack(TrackInfo);
        }       

        public ICommand PlayCommand { get; set; }
        
        public ICommand AddToPlaylistCommand { get; set; }

    }
}